package ru.spb.osll.myfit.client.widget;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class GWTWidgetFactory {
  public PopupPanel createPopupPanel() {
    return new PopupPanel(true);
  }

  public MenuBar createMenuBar() {
    return new MenuBar(true);
  }

  public MenuItem createMenuItem(String text, boolean asHTML, Command command) {
    return new MenuItem(text, asHTML, command);
  }

  public FlexTable createFlexTable() {
    return new FlexTable();
  }

  public VerticalPanel createVerticalPanel() {
    return new VerticalPanel();
  }

  public ScrollPanel createScrollPanel() {
    return new ScrollPanel();
  }

  public Composite createDisclosurePanel(String text, Widget contentWidget) {
    DisclosurePanel disclosurePanel = new DisclosurePanel(text);
    disclosurePanel.setAnimationEnabled(true);
    disclosurePanel.ensureDebugId("cwDisclosurePanel");
    disclosurePanel.setContent(contentWidget);

    return disclosurePanel;
  }

  public Composite createDisclosurePanelWithoutHeader(Widget contentWidget) {
    DisclosurePanel disclosurePanel = new DisclosurePanel();
    disclosurePanel.setAnimationEnabled(true);
    disclosurePanel.ensureDebugId("cwDisclosurePanel");
    disclosurePanel.setContent(contentWidget);

    return disclosurePanel;
  }

  public DecoratorPanel createDecoratorPanel() {
    return new DecoratorPanel();
  }

  public MyFlexTable createMyFlexTable() {
    return new MyFlexTable();
  }

  public HTML createHTML(String html) {
    return new HTML(html);
  }

  public TextArea createTextArea(String text) {
    TextArea textArea = new TextArea();
    textArea.setText(text);
    return textArea;
  }
}
